package com.ssy.lingxi.member.merchant.entity;

import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToFileListConverter;
import com.ssy.lingxi.member.merchant.model.bo.FileBO;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 会员投诉与建议
 * @author yzc
 * @version 2.0.0
 * @date 2021/5/17
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_complaint")
public class MemberComplaintDO implements Serializable {
    private static final long serialVersionUID = -7491976550577131570L;

    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_complaint_seq")
    @SequenceGenerator(sequenceName = "ms_mc_member_complaint_seq", name = "member_complaint_seq", allocationSize = 1)
    private Long id;

    /**
     * 业务类型 1-投诉 2-建议
     */
    @Column
    private Integer type;

    /**
     * 投诉类型 1-上级发起 2-下级发起
     */
    @Column
    private Integer complaintType;

    /**
     * 事件分类 1-关于产品 2-关于订单 3-关于配送 4-关于售后 5-关于服务 6-其他
     */
    @Column
    private Integer classify;

    /**
     * 状态 1-待提交投诉建议 2-待处理投诉建议 3-已处理投诉建议
     */
    @Column
    private Integer status;

    /**
     * 事件主题
     */
    @Column(columnDefinition = "varchar(50)")
    private String subject;

    /**
     * 多对一单向关联会员(投诉方)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "member_id", referencedColumnName = "id")
    private MemberDO member;

    /**
     * 投诉方角色id
     */
    @Column
    private Long roleId;

    /**
     * 多对一单向关联会员(被投诉方)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "sub_member_id", referencedColumnName = "id")
    private MemberDO subMember;

    /**
     * 被投诉方角色id
     */
    @Column
    private Long subRoleId;

    /**
     * 多对一单向关联下级会员用户(提出人)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "by_user_id", referencedColumnName = "id")
    private MemberUserDO byUser;

    /**
     * 提出人名称, 当byUser为null的时候,该字段有值,即byUser是数据库的数据, 该字段为用户编辑的数据
     */
    @Column
    private String byUserEditName;

    /**
     * 提出人手机, 当byUser为null的时候,该字段有值,即byUser是数据库的数据, 该字段为用户编辑的数据
     */
    @Column
    private String byUserEditPhone;

    /**
     * 事件时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime eventTime;

    /**
     * 事件描述
     */
    @Column(columnDefinition = "varchar(120)")
    private String eventDesc;

    /**
     * 事件建议
     */
    @Column(columnDefinition = "varchar(120)")
    private String eventSuggest;

    /**
     * 事件附件
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> attachments;

    /**
     * 创建时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 多对一单向关联下级会员用户(处理人)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "handle_user_id", referencedColumnName = "id")
    private MemberUserDO handleUser;

    /**
     * 处理人名称, 当handleUser为null的时候,该字段有值,即handleUser是数据库的数据, 该字段为用户编辑的数据
     */
    @Column
    private String handleUserEditName;

    /**
     * 处理人手机, 当byUser为null的时候,该字段有值,即byUser是数据库的数据, 该字段为用户编辑的数据
     */
    @Column
    private String handleUserEditPhone;

    /**
     * 处理结果
     */
    @Column(columnDefinition = "varchar(60)")
    private String handleResult;

    /**
     * 处理时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime handleTime;

    /**
     * 处理附件
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> handleAttachments;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getComplaintType() {
        return complaintType;
    }

    public void setComplaintType(Integer complaintType) {
        this.complaintType = complaintType;
    }

    public Integer getClassify() {
        return classify;
    }

    public void setClassify(Integer classify) {
        this.classify = classify;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public MemberDO getMember() {
        return member;
    }

    public void setMember(MemberDO member) {
        this.member = member;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public MemberDO getSubMember() {
        return subMember;
    }

    public void setSubMember(MemberDO subMember) {
        this.subMember = subMember;
    }

    public Long getSubRoleId() {
        return subRoleId;
    }

    public void setSubRoleId(Long subRoleId) {
        this.subRoleId = subRoleId;
    }

    public MemberUserDO getByUser() {
        return byUser;
    }

    public void setByUser(MemberUserDO byUser) {
        this.byUser = byUser;
    }

    public String getByUserEditName() {
        return byUserEditName;
    }

    public void setByUserEditName(String byUserEditName) {
        this.byUserEditName = byUserEditName;
    }

    public String getByUserEditPhone() {
        return byUserEditPhone;
    }

    public void setByUserEditPhone(String byUserEditPhone) {
        this.byUserEditPhone = byUserEditPhone;
    }

    public LocalDateTime getEventTime() {
        return eventTime;
    }

    public void setEventTime(LocalDateTime eventTime) {
        this.eventTime = eventTime;
    }

    public String getEventDesc() {
        return eventDesc;
    }

    public void setEventDesc(String eventDesc) {
        this.eventDesc = eventDesc;
    }

    public String getEventSuggest() {
        return eventSuggest;
    }

    public void setEventSuggest(String eventSuggest) {
        this.eventSuggest = eventSuggest;
    }

    public List<FileBO> getAttachments() {
        return attachments;
    }

    public void setAttachments(List<FileBO> attachments) {
        this.attachments = attachments;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public MemberUserDO getHandleUser() {
        return handleUser;
    }

    public void setHandleUser(MemberUserDO handleUser) {
        this.handleUser = handleUser;
    }

    public String getHandleUserEditName() {
        return handleUserEditName;
    }

    public void setHandleUserEditName(String handleUserEditName) {
        this.handleUserEditName = handleUserEditName;
    }

    public String getHandleUserEditPhone() {
        return handleUserEditPhone;
    }

    public void setHandleUserEditPhone(String handleUserEditPhone) {
        this.handleUserEditPhone = handleUserEditPhone;
    }

    public String getHandleResult() {
        return handleResult;
    }

    public void setHandleResult(String handleResult) {
        this.handleResult = handleResult;
    }

    public LocalDateTime getHandleTime() {
        return handleTime;
    }

    public void setHandleTime(LocalDateTime handleTime) {
        this.handleTime = handleTime;
    }

    public List<FileBO> getHandleAttachments() {
        return handleAttachments;
    }

    public void setHandleAttachments(List<FileBO> handleAttachments) {
        this.handleAttachments = handleAttachments;
    }
}
